<html><head><title>Window3D.pb</title></head>
<body bgcolor="#EFF1F0" link="#3A3966" vlink="#000000" alink="#000000">
<pre><font face="Courier New, Courier, mono"size="2"><font color="#3A3966">;
</font><font color="#3A3966">; ------------------------------------------------------------
</font><font color="#3A3966">;
</font><font color="#3A3966">;   PureBasic - Window 3D
</font><font color="#3A3966">;
</font><font color="#3A3966">;    (c) Fantaisie Software
</font><font color="#3A3966">;
</font><font color="#3A3966">; ------------------------------------------------------------
</font><font color="#3A3966">;
</font>  
<font color="#924B72">#MainWindow</font> = 0
<font color="#924B72">#CloseButton</font> = 0

<b><font color="#3A3966">IncludeFile</font></b> <font color="#924B72">#PB_Compiler_Home</font> + &quot;examples/3d/Screen3DRequester.pb&quot;

<b><font color="#3A3966">Define</font></b>.f KeyX, KeyY, MouseX, MouseY

<b><font color="#3A3966">If</font></b> <font color="#3A3966">InitEngine3D</font>()
  
<font color="#3A3966">  Add3DArchive</font>(<font color="#924B72">#PB_Compiler_Home</font> + &quot;examples/3d/Data/GUI&quot;, <font color="#924B72">#PB_3DArchive_FileSystem</font>)
<font color="#3A3966">  Add3DArchive</font>(<font color="#924B72">#PB_Compiler_Home</font> + &quot;examples/3d/Data/Packs/desert.zip&quot;, <font color="#924B72">#PB_3DArchive_Zip</font>)

    
<font color="#3A3966">  InitSprite</font>()
<font color="#3A3966">  InitKeyboard</font>()
<font color="#3A3966">  InitMouse</font>()
  
  <b><font color="#3A3966">If</font></b> <font color="#3A3966">Screen3DRequester</font>()
    
<font color="#3A3966">    SkyBox</font>(&quot;desert07.jpg&quot;)

<font color="#3A3966">    CreateCamera</font>(0, 0, 0, 100, 100)  <font color="#3A3966">; Front camera
</font><font color="#3A3966">    MoveCamera</font>(0,0,100,100, <font color="#924B72">#PB_Absolute</font>)
    
    
<font color="#3A3966">    OpenWindow3D</font>(<font color="#924B72">#MainWindow</font>, 100, 100, 300, 100, &quot;Hello in 3D !&quot;)
		
<font color="#3A3966">			ButtonGadget3D</font>(<font color="#924B72">#CloseButton</font>, 150, 40, 120, 25, &quot;Quit&quot;)
			
<font color="#3A3966">  	ShowGUI</font>(128, 1) <font color="#3A3966">; Display the GUI, semi-transparent and display the mouse cursor
</font>    		
    <b><font color="#3A3966">Repeat</font></b>
<font color="#3A3966">      Screen3DEvents</font>()

      <b><font color="#3A3966">If</font></b> <font color="#3A3966">ExamineKeyboard</font>() <b><font color="#3A3966">And</font></b> <font color="#3A3966">ExamineMouse</font>()
        Input$ =<font color="#3A3966"> KeyboardInkey</font>()
        
<font color="#3A3966">        InputEvent3D</font>(<font color="#3A3966">MouseX</font>(),<font color="#3A3966"> MouseY</font>(),<font color="#3A3966"> MouseButton</font>(<font color="#924B72">#PB_MouseButton_Left</font>), Input$, 0)
      <b><font color="#3A3966">EndIf</font></b>
      
      <font color="#3A3966">; Handle the GUI 3D events, it's similar to regular GUI events
</font>      <font color="#3A3966">;
</font>      <b><font color="#3A3966">Repeat</font></b>
      	Event =<font color="#3A3966"> WindowEvent3D</font>()
      	
      	<b><font color="#3A3966">Select</font></b> Event
      		<b><font color="#3A3966">Case</font></b> <font color="#924B72">#PB_Event3D_CloseWindow</font>
      		  <b><font color="#3A3966">If</font></b> <font color="#3A3966">EventWindow3D</font>() = <font color="#924B72">#MainWindow</font>
<font color="#3A3966">      		    CloseWindow3D</font>(<font color="#924B72">#MainWindow</font>)
      		  <b><font color="#3A3966">EndIf</font></b>
      		  
      		<b><font color="#3A3966">Case</font></b> <font color="#924B72">#PB_Event3D_Gadget</font>
      		  <b><font color="#3A3966">If</font></b> <font color="#3A3966">EventGadget3D</font>() = <font color="#924B72">#CloseButton</font>
      		    Quit = 1
      		  <b><font color="#3A3966">EndIf</font></b>
      			
      	<b><font color="#3A3966">EndSelect</font></b>
     	<b><font color="#3A3966">Until</font></b> Event = 0
     	
<font color="#3A3966">      RenderWorld</font>()
      
<font color="#3A3966">      FlipBuffers</font>()
    <b><font color="#3A3966">Until</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Escape</font>) <b><font color="#3A3966">Or</font></b> Quit = 1
  <b><font color="#3A3966">EndIf</font></b>
    
<b><font color="#3A3966">Else</font></b>
<font color="#3A3966">  MessageRequester</font>(&quot;Error&quot;, &quot;The 3D Engine can't be initialized&quot;, 0)
<b><font color="#3A3966">EndIf</font></b></font></pre>
</body></html>
